package cmd

import (
	"fmt"
	"lwa-go/services"
	"strconv"

	"github.com/spf13/cobra"
)

var resetOrderNumCommand = &cobra.Command{
	Use:   "reset-order-num",
	Short: "reset chapter's order num",
	Long:  "reset chapter's order num start from 1",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) < 1 {
			fmt.Println("缺少参数: novel id")
			return
		}
		novelIdString := args[0]
		novelId, _ := strconv.Atoi(novelIdString)
		chapterSer := services.ChapterService{}
		chapterSer.ResetOrderNum(novelId)
	},
}

func init() {
	rootCmd.AddCommand(resetOrderNumCommand)
}
